home *** CD-ROM | disk | FTP | other *** search
/ Micromanía: 150 Juegos 2010 / 150Juegos_16.iso / Shareware / Juegos Flash / canyonZone.dcr / Internal_105_checkStates.ls < prev    next >
Encoding:
Text File  |  2003-08-01  |  2.0 KB  |  53 lines

  1. on checkStates tStates
  2.   tCollisions = []
  3.   repeat with i = 1 to tStates.count
  4.     if tStates[i][#crashed] = 1 then
  5.       next repeat
  6.     end if
  7.     repeat with ii = i + 1 to tStates.count
  8.       if tStates[ii][#crashed] = 1 then
  9.         next repeat
  10.       end if
  11.       t = stateCollidingWithState(tStates[i], tStates[ii])
  12.       if t <> 0 then
  13.         tCollisions.append([i, ii, t])
  14.       end if
  15.     end repeat
  16.   end repeat
  17.   return tCollisions
  18. end
  19.  
  20. on stateCollidingWithState tState1, tState2
  21.   if getDistanceSquared(tState1[#position], tState2[#position]) > 10000 then
  22.     return 0
  23.   end if
  24.   tForward = 47 / 2
  25.   tBackward = -47 / 2
  26.   tWidth = 37 / 2
  27.   tPos = tState1[#position]
  28.   tAngle = tState1[#angle]
  29.   tRF = tPos + (getVector(tAngle) * tForward) + (getVector(tAngle + (PI / 2)) * tWidth)
  30.   tLF = tPos + (getVector(tAngle) * tForward) - (getVector(tAngle + (PI / 2)) * tWidth)
  31.   tRB = tPos + (getVector(tAngle) * tBackward) + (getVector(tAngle + (PI / 2)) * tWidth)
  32.   tLB = tPos + (getVector(tAngle) * tBackward) - (getVector(tAngle + (PI / 2)) * tWidth)
  33.   tPoints1 = [tRF, tLF, tRB, tLB]
  34.   tPos = tState2[#position]
  35.   tAngle = tState2[#angle]
  36.   tRF = tPos + (getVector(tAngle) * tForward) + (getVector(tAngle + (PI / 2)) * tWidth)
  37.   tLF = tPos + (getVector(tAngle) * tForward) - (getVector(tAngle + (PI / 2)) * tWidth)
  38.   tRB = tPos + (getVector(tAngle) * tBackward) + (getVector(tAngle + (PI / 2)) * tWidth)
  39.   tLB = tPos + (getVector(tAngle) * tBackward) - (getVector(tAngle + (PI / 2)) * tWidth)
  40.   tPoints2 = [tRF, tLF, tRB, tLB]
  41.   repeat with tPoint in tPoints1
  42.     if point_inside_rot_rect(tPoint[1], tPoint[2], tPoints2[1][1], tPoints2[1][2], tPoints2[2][1], tPoints2[2][2], tPoints2[3][1], tPoints2[3][2]) then
  43.       return tPoint
  44.     end if
  45.   end repeat
  46.   repeat with tPoint in tPoints2
  47.     if point_inside_rot_rect(tPoint[1], tPoint[2], tPoints1[1][1], tPoints1[1][2], tPoints1[2][1], tPoints1[2][2], tPoints1[3][1], tPoints1[3][2]) then
  48.       return tPoint
  49.     end if
  50.   end repeat
  51.   return 0
  52. end
  53.